package com.example.studyspringdemo.controller;

import com.example.studyspringdemo.bean.User;
import com.example.studyspringdemo.biz.UserBiz;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserBiz userBiz;

    @RequestMapping(value = "/all",method = RequestMethod.GET)
    public List<User> selectAll(){
        log.info(">>>>>>>>>>>>>>>>>>>>>>>>>selectAll");
        return userBiz.selectAll();
    }

    @GetMapping(value="/checkUserName")
    public boolean checkUserName(String userName){
        return userBiz.checkUserName(userName);
    }

    @GetMapping(value="/checkEmail")
    public boolean checkEmail(String email){
        return userBiz.checkEmail(email);
    }

    @PostMapping(value = "/saveUser")
    public int saveUser(@RequestBody User user){
        return userBiz.saveUser(user);
    }
}
